package com.xyht.medicine_management_system.modules.search.controller;


import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.search.service.MmsSearchService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 首页搜索记录表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-02-18
 */
@RestController
@RequestMapping("/search")
@SecretBody
public class MmsSearchController {

    @Resource
    private MmsSearchService mmsSearchService;

    @ApiOperation("搜索")
    @GetMapping("/list")
    public ResponseResult searchMedicineList(@RequestParam(value = "keyword",required = false)String keyword,
                                             @RequestParam(value = "searchType")Integer searchType,
                                             @RequestParam(value = "upDown",required = false)Integer upDown,
                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        return mmsSearchService.searchMedicineList(keyword,searchType,upDown,pageNum,pageSize);
    }

    @ApiOperation("输入关键词")
    @GetMapping("/enterKeyword")
    public ResponseResult searchEnterKeywordList(@RequestParam(value = "keyword",required = false)String keyword,
                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        return mmsSearchService.searchEnterKeywordList(keyword,pageNum,pageSize);
    }

    @ApiOperation("获取热搜关键词")
    @GetMapping("/hotKeyword")
    public ResponseResult getHotKeywordList(){
        return mmsSearchService.getHotKeywordList();
    }

}

